package com.example.test_witns.adapter.viewPageAdapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.test_witns.ui.view_pages_home.ViewPageHotFragment;
import com.example.test_witns.ui.view_pages_home.ViewPageInterviewSkillsFragment;
import com.example.test_witns.ui.view_pages_home.ViewPageLatestFragment;
import com.example.test_witns.ui.view_pages_home.ViewPageSubscribeFragment;

public class ScreenSlidePagerAdapter extends FragmentStateAdapter {
    private static final int NUM_PAGES = 4;

    public ScreenSlidePagerAdapter(FragmentActivity fa) {
        super(fa);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        // 返回一个 Fragment 实例
        switch (position){
            case 0 : return new ViewPageSubscribeFragment();
            case 1 : return new ViewPageHotFragment();
            case 2 : return new ViewPageLatestFragment();
            case 3 : return new ViewPageInterviewSkillsFragment();
            default : return new ViewPageHotFragment();
        }
    }

    @Override
    public int getItemCount() {
        return NUM_PAGES;
    }
}